import u from "../utils";
import { APP } from "../constants";
import { WeaLocaleProvider } from "ecCom";
const getLabel = WeaLocaleProvider.getLabel;

const _api = u.api(APP);

export default {
    getApps: params => _api('list', { data: params }),
    getLeftDatas: params => _api('getLeftDatas', { data: params }),
    getDisplayTypes: () => _api('getDisplayType'),
    getFillinTypes: () => _api('getFillinType'),
    info: appid => _api('info', {
        type: 'get',
        data: { appid }
    }),
    create: (appinfo) => _api('create', {
        type: 'post',
        data: { appinfo: JSON.stringify(appinfo) },
        msg: getLabel('502228', '新建成功')
    }),
    innerCreate: (appinfo) => _api('innerCreate', { type: 'post', data: { appinfo: JSON.stringify(appinfo) } }),
    edit: (appinfo) => _api('modify', {
        type: 'post',
        data: { appinfo: JSON.stringify(appinfo) },
        msg: getLabel('502229', '编辑成功')
    }),
    delete: appids => _api('delete', {
        data: { appids },
        msg: getLabel('502230', '删除成功')
    }),
    getBoard: appid => _api('getBoardInfoWithApp', { data: { appid } }),
    existsForm: appid => _api('existsForm', { data: { appid } }),
    share: share => _api('share', { data: share, type: 'post' }),
    getSearchItems: params => _api('getSearchItems', { data: params, type: 'get' }),
    checkCreateMaxNum: params => _api('checkCreateMaxNum', { data: params, type: 'get' }),
    exportApp: (appids) => _api('exportApp', { data: { appids }, type: 'get' }),
    copyApp: copyApp => _api('copyApp', { data: copyApp, type: 'post' }),
    getSubmitCount: (appid) => _api('form/submittedCount', { data : { appid }}),
    getBaseInfo: (appid) => _api('form/baseInfo', { data: { appid }}),
    getAppTaskSetting: appid => _api('getAppTaskSetting', { data: { appid }, type: 'get' }),
    saveAppTaskSetting: params => _api('saveAppTaskSetting', { data: params, type: 'post' }),
    getSubmitAuthInfo: (appid) => _api('form/submitAuthInfo', { data: { appid } }),
    submitAuthChange: (data) => _api('form/submitAuthChange', { type: 'post', data: data }),
    delSubmitMember: (data) => _api('form/submitMemberDel', { type: 'post', data: data }),
    getConversationInfo: (data) => _api('form/getConversationInfo', { data: data }),
    getExceptMembers: (data) => _api('form/getExceptMembers', { data: data }),
    modifyExceptMembers: (data) => _api('form/modifyExceptMembers', { type: 'post', data: data }),
    addSubmitMember: (data) => _api('form/submitMemberAdd', { type: 'post', data: data }),
    statisticsMembers: (data) => _api('form/statisticsMembers', { data: data }),
    fillinRemind: (data) => _api('form/fillinRemind', {data: data, type: 'post'}),
    getBoardWidgets: (appid) => _api('getBoardWidgets', { data: { appid }}),
    getAppHasRighters: (appid) => _api('getAppHasRighters', { data: { appid } }),
    updateCubeAppIdToEdc:params => _api('updateCubeAppIdToEdc', { data: params, type: 'post' }),
    getAppModeInfo:params => _api('getAppModeInfo', { data: params, type: 'get' }),
  }

export const shareList = appid => _api('shareList', { data: { appid } });
export const deleteShare = (ids, appid) => _api('deleteShare', { data: { appid, ids }, type: 'post' });